package com.jcxy.controller;

import com.jcxy.mapper.AttendanceMapper;
import com.jcxy.pojo.User;
import com.jcxy.service.AttendanceService;
import com.jcxy.util.PageBean;
import com.jcxy.util.ParamsDto;
import com.jcxy.util.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@Controller
@RequestMapping("/attendanceList")
public class AttendanceListController {

    @Autowired
    private AttendanceService attendanceService;

    /**
     * 通过分页获得用户列表
     * @return
     */
    @RequestMapping("/getMyAttendanceListByPage.do")
    @ResponseBody
    public ResponseData getMyAttendanceListByPage(HttpServletRequest request){


        //将参数转换成合适的map集合
        Map dto = ParamsDto.getDto(request.getParameterMap());
        User user = (User) request.getSession().getAttribute("user");
        dto.put("user_id",user.getUser_id());

        //调用业务逻辑层方法，查询角色列表
        PageBean pageBean = attendanceService.queryListByPage(
                dto,//查询条件
                Integer.valueOf(dto.get("page").toString()),//当前页
                Integer.valueOf(dto.get("limit").toString()));//页容量

        return pageBean.getResponseData();
    }

}
